package servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Impl.MasterDaoMySQLImpl;
import entitys.TopicWork;
import entitys.newsWork;

public class UpdataTitle extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
			
		out.println(request.getParameter("tid"));
		out.println(request.getParameter("newname"));

		int tid = Integer.parseInt(request.getParameter("tid").toString());
		String tname = (String) request.getParameter("newname");

		
		
		System.out.println(tid + "000000" + tname);
		// 操作数据库

		MasterDaoMySQLImpl mySQLImpl = new MasterDaoMySQLImpl();
		TopicWork topic = new TopicWork();
		topic.setTid(tid);
		topic.setTname(tname);
		int num = mySQLImpl.updateTopic(topic);

		if (num > 0) {
			out.print("更新成功！");
			System.out.print("更新成功！");
		} else {
			out.print("更新失败");
			System.out.print("更新失败");
		}
	}

}
